﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for cart
/// </summary>
public class cart:IEquatable<cart>
{
    private int product_id;

    public int Product_id
    {
        get { return product_id; }
        set {
            product = null;
            product_id = value; 
        }
    }
    private int quantity;

    public int Quantity
    {
        get { return quantity; }
        set { quantity = value; }
    }
    private product product=null;

    public product Product
    {
        get { 
            if(product==null){
                productBus probus=new productBus();
                product=probus.getProducstByID(product_id);
                
            }
            return product; 
        }
        set { product = value; }
    }
	public cart()
	{
		//
		// TODO: Add constructor logic here
		//
        
	}
    
    public cart(int product_id)
    {
        this.Product_id = product_id;
        //this.Product();
    }
    //Hàm so sánh
    public bool Equals(cart item)
    {
        return this.Product_id == item.Product_id;//nếu Product_id giống nhau thì 2 object giống nhau
    }
    public bool checkquantity()
    {
        bool b = true;
        if (quantity > Product.Product_quantity)
        {
            b = false;
        }
        return b;
    }
    
}